<template>
  <SysDialog draggable :title="dialog.title" :visible="dialog.visible" :width="dialog.width" :height="dialog.height"
    @onClose="onClose" @onConfirm="confirm">
    <template v-slot:content>
      <!-- 内容组件 -->
      <el-form :model="dialogModel" ref="addTestCaseForm" :rules="rules" label-width="120px" size="default">
        <el-form-item prop="testName" label="测试用例名称">
          <el-input v-model="dialogModel.testName" clearable></el-input>
        </el-form-item>
      </el-form>
    </template>
  </SysDialog>
</template>
  
<script setup lang='ts'>
import { ref, nextTick } from 'vue'
import SysDialog from '@/components/SysDialog.vue';
import useDialog from '@/hooks/useDialog';
import useInstance from '@/hooks/useInstance';
import { ElForm } from 'element-plus'
import { EditType, Title } from '@/type/BaseEnum';
import caseModel from '@/composables/03organization/05testCase/caseAddModel'
import { log } from 'console';
// 使用
const addTestCaseForm = ref<InstanceType<typeof ElForm>>()
const emit = defineEmits(['save'])
const { dialog, onClose, onShow } = useDialog()
const { global, proxy } = useInstance();
const { rules, dialogModel } = caseModel()
// 父级数据
const props = defineProps({
  fileType: {
    type: [String, Number],
    default: 0
  },
  childId: {
    type: String,
    default: ''
  }
})
// 保存
const confirm = () => {
  addTestCaseForm?.value?.validate((isOk) => {
    if (isOk) {
      console.log('数据校验');
      emit('save', dialogModel)
      onClose()
    }
  })
}
const show = (type: string, row?: any) => {
  dialog.width = 650
  nextTick(() => {
    if (props.childId) {
      dialogModel.pid = props.childId
    }
    console.log(dialogModel);
  })
  dialog.height = 270
  dialog.title = type == EditType.ADD ? Title.ADD : Title.EDIT
  onShow()
  dialogModel.testName = ''
}
defineExpose({
  show
})
</script>
<style lang="scss">
.custom-select {

  //  width: 505px;
  .el-scrollbar__view {
    display: flex;
    flex-wrap: wrap;
    width: 505px;

    .el-select-dropdown__item {
      padding: 0 20px 0 20px;
    }
  }
}
</style>
<style scoped lang='scss'></style>